
/*
 * Java class "LinearTargeting.java" generated from Poseidon for UML.
 * Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>.
 * Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine.
 */
package jcs;



/**
 * <p></p>
 * @poseidon-object-id [sm$aaca8a:ffff2170b8:-7f3e]
 */
public class LinearTargeting extends TargetingMode {

  ///////////////////////////////////////
  // operations


/**
 * <p>Does ...</p>
 * 
 * @poseidon-object-id [sm$aaca8a:ffff2170b8:-7f63]
 * @return 
 * @param target 
 */
    public double calcBulletPower(Enemy target) {        
        double distance = seth.getCurrentPos().calcDist(target.getCoord());  
        double power = 3.0;
        
                      /*  double scalar = 0.90;
                        if(distance > POWER_BUFFER)
                        {
                        	scalar = POWER_BUFFER / distance;
                        }
                        else
                        {
                        	scalar = 0.0;	
                        }
                        double power = 3.0 * (1.0 - scalar);
                        return power;
         **/
        
        if(distance < POWER_BUFFER)
        {
            power = 3.0;
        }
        else
        {
            double temp = distance - POWER_BUFFER + 1;
            power = 3.0 * POWER_BUFFER * (target.getRatio(0) / distance);
        }
        
        if(seth.getEnergy() < 9.1 && power > seth.getEnergy())
        {
            power = seth.getEnergy() / 3.0;
        }
        if( power * 4.0 > target.getEnergy())
        {
            power = target.getEnergy() / 4.0;
        }
        return power;
    } // end calcBulletPower        

/**
 * <p>Does ...</p>
 * 
 * @poseidon-object-id [sm$aaca8a:ffff2170b8:-7f62]
 * @return 
 * @param target 
 * @param time 
 */
    public double calcPoint(Enemy target, double time) {        
        // a direct linear gun, point it at where they are going
        double difference = seth.getCurrentPos().calcDist(target.getCoord());
        // Lead Point
        double distance = target.getVelocity() * time;
        Coord leadCoord = target.getCoord().getCoordFromScan( target.getBearing(), distance );
        System.out.println("firing by Linear Targeting");
        return seth.getCurrentPos().calcHeading( leadCoord );
    } // end calcPoint        

/**
 * <p>Does ...</p>
 * 
 * @poseidon-object-id [sm$31b810:ffff82645c:-7fa0]
 * @param _seth 
 */
    public  LinearTargeting(Seth _seth) {        
        seth = _seth;
    } // end LinearTargeting        

 } // end LinearTargeting


